package com.lagou.homework.third;

/**
 * 手机卡类
 */
public class PhoneCard {
    /**
     * 卡类型
     */
    private PhoneCardType type;
    /**
     * 卡号
     */
    private String cardNum;
    /**
     * 用户名
     */
    private String accountName;
    /**
     * 密码
     */
    private String password;
    /**
     * 账户余额
     */
    private double balance;
    /**
     * 通话时长
     */
    private int time;
    /**
     * 上网流量
     */
    private double traffic;

    /**
     * 无参构造方法
     */
    public PhoneCard() {
    }

    /**
     * 有参构造方法
     * @param type          卡类型
     * @param cardNum       卡号
     * @param accountName   用户名
     * @param password      密码
     * @param balance       账户余额
     * @param time          通话时长
     * @param traffic       上网流量
     */
    public PhoneCard(PhoneCardType type, String cardNum, String accountName, String password, double balance, int time, double traffic) {
        setType(type);
        setCardNum(cardNum);
        setAccountName(accountName);
        setPassword(password);
        setBalance(balance);
        setTime(time);
        setTraffic(traffic);
    }

    public PhoneCardType getType() {
        return type;
    }

    public void setType(PhoneCardType type) {
        this.type = type;
    }

    public String getCardNum() {
        return cardNum;
    }

    public void setCardNum(String cardNum) {
        this.cardNum = cardNum;
    }

    public String getAccountName() {
        return accountName;
    }

    public void setAccountName(String accountName) {
        this.accountName = accountName;
    }

    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    public double getBalance() {
        return balance;
    }

    public void setBalance(double balance) {
        this.balance = balance;
    }

    public int getTime() {
        return time;
    }

    public void setTime(int time) {
        if (time >= 0) {
            this.time = time;
        } else {
            System.out.println("通话时长数值不合理");
        }
    }

    public double getTraffic() {
        return traffic;
    }

    public void setTraffic(double traffic) {
        if (traffic >= 0.0) {
            this.traffic = traffic;
        } else {
            System.out.println("上网流量数值不合理");
        }
    }

    public void show() {
        System.out.println("您的卡号：" + getCardNum() + "，用户名：" + getAccountName() + "，当前余额：" + getBalance());
    }
}
